<template>
  <div id="app">
    <el-container>
      <el-header v-show="show">
        <div class="el-icon-s-fold" @click="flag = !flag"></div>
        <el-dropdown @command="tui">
          <span class="el-dropdown-link">
            超级管理员<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>设置</el-dropdown-item>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-container>
        <el-aside width="200px" v-show="show">
          <el-menu
            :collapse="flag"
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            router
            active-text-color="#ffd04b"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-promotion"></i>
                <span>基础管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/jichu">商品管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-shopping-cart-2"></i>
                <span>订单管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/dingdan">交易订单</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-custom"></i>
                <span>系统管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/xitong">用户管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span>支付管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/zhifu">支付配置信息</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <crumb class="crumb" v-show="show"></crumb>
        <el-main><router-view></router-view></el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import crumb from "./components/crumb";
export default {
  components: {
    crumb,
  },
  data() {
    return {
      show: false,
      flag: false,
    };
  },
  methods: {
    // 退出登录
    tui() {
      this.$confirm("确定退出吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$message({
          type: "success",
            message: "退出登录成功!",
          });
          localStorage.removeItem("token");
          this.$router.push({ path: "/login" });
          this.$http("http://ceshi5.dishait.cn/admin/logout", "post");
        }).catch(() => {
          this.$message({
            type: "info",
            message: "已取消退出登录",
          });
        });
    },
  },
  // 监听   如果是登录页面就隐藏
  watch: {
    "$route.path": {
      handler(newval, oldval) {
        if (newval == "/login") {
          this.show = false;
        } else {
          this.show = true;
        }
      },
    },
  },
};
</script>
<style scoped>
.el-header,
.el-footer {
  color: #333;
  text-align: center;
  line-height: 60px;
  background: #9bacbd;
}

.el-aside {
  color: #333;
  text-align: center;
  line-height: 200px;
  border-top: 1px solid #fff;
}

.el-main {
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-icon-s-fold {
  float: left;
  margin-left: 200px;
  font-size: 28px;
  margin-top: 15px;
  color: #fff;
}
.el-dropdown-link {
  margin-left: 1000px;
  color: #fff;
  float: left;
}
.crumb {
  width: 200px;
  margin-top: 20px;
  margin-left: 30px;
  height: 30px;
}
</style>
